package com.lagou.dubbo;

import com.lagou.dubbo.consumer.Consumer;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;
import java.util.concurrent.*;

public class ConsumerApplication {


    public static void main(String[] args) throws IOException, InterruptedException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();
        Consumer service = context.getBean(Consumer.class);
        ExecutorService executorService = new ThreadPoolExecutor(10,10,60L, TimeUnit.SECONDS,new ArrayBlockingQueue(100000));
        while (true){
            executorService.execute(()->{
                service.delete();
            });
            executorService.execute(()->{
                service.update();
            });
            executorService.execute(()->{
                service.insert();
            });
        }

    }

    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    //@EnableDubbo(scanBasePackages = "com.lagou.bean")
    @ComponentScan("com.lagou.dubbo.consumer")
    @EnableDubbo
    static class ConsumerConfiguration {

    }

}
